<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        function doBack(){
            window.history.back();//由于window是顶层对象，所以是可以省略的
        }
        function doForward(){
            window.history.forward();
        }
        function doGo(){
            window.history.go(2);
        }
        function doGo2(){
            window.history.go(-1);
        }
        function doGo3(){
            window.history.go(0);//刷新
        }
        function getLoc(){
            console.log(window.location.href);
        }
        function setLoc(){
            window.location.href="http://www.baidu.com";
        }
        function refresh(){
            window.location.reload();//刷新
        }
    </script>
</head>
<body>
    <input type="button" value="后退" onclick="doBack()">
    <input type="button" value="前进" onclick="doForward()">
    <input type="button" value="前进2页" onclick="doGo()">
    <input type="button" value="后退一页" onclick="doGo2()">
    <input type="button" value="刷新" onclick="doGo3()">
    <input type="button" value="获取地址" onclick="getLoc()">
    <input type="button" value="设置地址,跳转地址" onclick="setLoc()">
    <input type="button" value="刷新" onclick="refresh()">
</body>
</html>